package com.example.mapdata.controller;


import com.example.mapdata.entity.Shop;
import com.example.mapdata.service.ShopService;
import com.example.mapdata.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * (Shop)表控制层
 *
 * @author makejava
 * @since 2024-09-20 10:56:13
 */
@RestController
@RequestMapping("/api/shop")
@CrossOrigin
public class ShopController {
    @Autowired
    private ShopService shopService;

    /**
     * 根据城市编号以及区县别名获取店铺信息
     *
     * @param cityId
     * @param areaId
     * @return
     */
    @GetMapping("get_shops")
    public ResultVo getShops(@RequestParam String cityId, @RequestParam String areaId) {
        List<Shop> shopByCityAndDistrict = shopService.getShopByCityAndDistrict(cityId, areaId);
        if (shopByCityAndDistrict.size() == 0) {
            return new ResultVo("没有找到该区域下的店铺", false);
        } else {
            return new ResultVo(shopByCityAndDistrict);
        }
    }
}

